﻿using System;
using CoreTypes;
using System.Windows.Forms;

namespace MainModule
{
   public partial class InputDialog : Form
   {
      static string FValue;

      InternetCommunicator FCommunicator = InternetCommunicator.Self;

      public InputDialog(string caption, string paramName, string paramValue)
      {
         InitializeComponent();

         Text = caption;
         labelParameter.Text = paramName;
         textBoxParameter.Text = paramValue;
         textBoxParameter.Select();
         textBoxParameter.SelectAll();
      }

      public static DialogResult Show(string caption, string paramName, string paramValue)
      {
         return new InputDialog(caption, paramName, paramValue).ShowDialog();
      }

      public static string Value
      {
         get
         {
            return FValue;
         }
      }

      private void buttonOk_Click(object sender, EventArgs e)
      {
         FValue = textBoxParameter.Text;
      }
      private void buttonCancel_Click(object sender, EventArgs e)
      {
         FValue = null;
      }
      private void panelBase_Paint(object sender, PaintEventArgs e)
      {
         FCommunicator.DrawTheme(FCommunicator.ColorTheme, e.Graphics, (sender as Control).ClientRectangle, ColorThemeObject.Pattern);
      }
      private void panelBottom_Paint(object sender, PaintEventArgs e)
      {
         FCommunicator.DrawTheme(FCommunicator.ColorTheme, e.Graphics, (sender as Control).ClientRectangle, ColorThemeObject.ToolStrip);
      }
      private void textBoxParameter_TextChanged(object sender, EventArgs e)
      {
         buttonOk.Enabled = textBoxParameter.Text.Length > 0;
      }
   }
}
